import axios from 'axios';
import type {
  Result,
} from './typings';

/**
 * 新增文章对应的统计信息 POST /api/statistic
 */
export async function post_api_statistic (
  data: {
    /** 是否允许评论 */
    allowComment?: boolean;
    /** 文章分类 */
    category?: string;
    /** 文章评论量 */
    commentNum?: number;
    /** 文章内容 */
    content?: string;
    /** 创建时间 */
    createTime?: string;
    /** 文章点击量 */
    hit?: number;
    /** 文章id */
    id?: number;
    /** 文章标签 */
    tag?: string;
    /** 文章缩略图 */
    thumbnail?: string;
    /** 文章标题 */
    title?: string;
    /** 更新时间 */
    updateTime?: string;
  },
  options?: Record<string, any>,
): Promise<Result<any>> {
  return axios({
    method: 'POST',
    url: `/api/statistic`,
    data: {
      ...data,
    },
    ...(options || {}),
  })
}

/**
 * 根据文章id查询点击量和评论量信息 POST /api/statistic/addStatistic
 */
export async function post_api_statistic_addStatistic (
  params: {
    /** 文章id */
    articleId?: number;
  },
  options?: Record<string, any>,
): Promise<Result<any>> {
  return axios({
    method: 'POST',
    url: `/api/statistic/addStatistic`,
    params: {
      ...params,
    },
    ...(options || {}),
  })
}

/**
 * 根据文章id删除统计数据 DELETE /api/statistic/delete
 */
export async function delete_api_statistic_delete (
  params: {
    /** 文章id */
    id?: number;
  },
  options?: Record<string, any>,
): Promise<Result<any>> {
  return axios({
    method: 'DELETE',
    url: `/api/statistic/delete`,
    params: {
      ...params,
    },
    ...(options || {}),
  })
}

/**
 * 统计文章热度信息 GET /api/statistic/getStatistic
 */
export async function get_api_statistic_getStatistic (
  options?: Record<string, any>,
): Promise<Result<any>> {
  return axios({
    method: 'GET',
    url: `/api/statistic/getStatistic`,
    ...(options || {}),
  })
}

/**
 * 统计博客文章总评论量 GET /api/statistic/getTotalComment
 */
export async function get_api_statistic_getTotalComment (
  options?: Record<string, any>,
): Promise<Result<any>> {
  return axios({
    method: 'GET',
    url: `/api/statistic/getTotalComment`,
    ...(options || {}),
  })
}

/**
 * 统计博客文章总访问量 GET /api/statistic/getTotalVisit
 */
export async function get_api_statistic_getTotalVisit (
  options?: Record<string, any>,
): Promise<Result<any>> {
  return axios({
    method: 'GET',
    url: `/api/statistic/getTotalVisit`,
    ...(options || {}),
  })
}

/**
 * 根据文章id更新评论量 POST /api/statistic/updateComments
 */
export async function post_api_statistic_updateComments (
  data: {
    /** 文章id */
    articleId?: number;
    /** 文章评论量 */
    commentNum?: number;
    /** 文章点击量 */
    hit?: number;
    /** 文章统计id */
    id?: number;
  },
  options?: Record<string, any>,
): Promise<Result<any>> {
  return axios({
    method: 'POST',
    url: `/api/statistic/updateComments`,
    data: {
      ...data,
    },
    ...(options || {}),
  })
}

/**
 * 根据文章id更新点击量 POST /api/statistic/updateHits
 */
export async function post_api_statistic_updateHits (
  data: {
    /** 文章id */
    articleId?: number;
    /** 文章评论量 */
    commentNum?: number;
    /** 文章点击量 */
    hit?: number;
    /** 文章统计id */
    id?: number;
  },
  options?: Record<string, any>,
): Promise<Result<any>> {
  return axios({
    method: 'POST',
    url: `/api/statistic/updateHits`,
    data: {
      ...data,
    },
    ...(options || {}),
  })
}
